""""
增
a = [1,2,3]
a.append(4) # 在列表末尾添加一个元素
a.extend([4,5,6])
b = ["Hello","world"]
a.extend(b) # 合并两个列表
print(a)


list.copy()
a = [1,2,3]
print(id(a))

b = a.copy() #复制后的地址与之前是不一致的
print(b)
print(id(b))

"""
import operator

# list.remove(obj) #删
# a = [1,2,3,4,5,6,7,8,9]
# # a.pop(6) # 括号内默认参数为-1，可修改
# # a.remove(3) # 删除指定元素
# print(a)

# list.clear()
# a = [1,2,3,4,5,6,7,8,9]
# a.clear() # 清空列表
# print(a)

#del list
# a = [1,2,3,4,5,6,7,8,9]
# del a #移除a这个变量对象
# print(a) #报错

# del a[3] #移除指定索引中的值
# print(a)

# list() #改
# a = "Razey Wendaoge"
# # print(list(a)) #将字符串转换为列表 ['R', 'a', 'z', 'e', 'y', ' ', 'W', 'e', 'n', 'd', 'a', 'o', 'g', 'e']
# b = list(a)
# print(b)
# b[0] = "Z"
# print(b)

#list.insert(index, obj) #在指定位置插入元素
# a = [1,2,3]
# a.insert(1,"一") # 在索引为1的位置插入元素(插入到前面)
# print(a)

## 查
#len()
# a = [1,2,3]
# print(len(a))

# max()
# a = [1,2,3]
# a = "Razey Wendaoge" #
# a = "南城"   #根据汉字的编码判断谁为最大
# # b = max(a)
# b = min(a)
# print(b)

# a = [1,2,3,"Hello world"] #反面举例
# b = max(a)
# print(b) #会报错，[]里面的内容应该是同类型的

# count(obj) # 统计某个元素在列表中出现的次数
# alphabet = ["a","b","c","a","b","a"]
# num = alphabet.count("a")
# print(num)

# index(obj) # 返回某个元素在列表中第一次出现的索引
# alphabet = ["a","b","c","b","a","b","a"]
# index = alphabet.index("b", 0,-1) #从索引为2的位置开始，到-1结束，查找b第一次出现的的索引下标
# print(index)

# 切片 slice[start : end :step]
# alphabet = ["a","b","c","b","a","b","a"]
# b = alphabet[2:-1,2] # 从索引为2的位置开始，到-1结束，步长为2
# print(b)


# reverse() #反转列表
# alphabet = ["a","b","c","b","a","b","a"]
# alphabet.reverse()
# print(alphabet) #['a', 'b', 'a', 'b', 'c', 'b', 'a']

# list.sort(key=None ,reverse=Flase) #排序
# fruits = ["banana","apple","banana","cherry","mango","pear"]
# fruits.sort() #默认是正序，按照abcdef的顺序排序
# fruits.sort(reverse=True) #倒序，按照abcdef的倒序排序
# fruits.sort(key=len,reverse=True) #按照字符串的长度进行排序
# print(fruits)


# list = [1,2,3,4,5,6,7,8,9]
# list.sort(key=lambda x: x%2) #按照奇偶性进行排序,默认偶数再前，基数在后排序
# print(list)

# x in list #判断某个元素是否在列表中
# list = [1,2,3,4,5,6,7,8,9]
# result = 5 not in list #判断某个元素是否不在列表中
# print(result) #False

# operator 模块
# a = [1,2,3]
# b = [4,5,6]
# c = [1,2,3]
#
# result = operator.eq(a,b) #判断两个列表是否相等
# print(result) #False

print(dir(list)) #查看list的方法